package com.gzw.scm.DEL;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Administrator on 2017/4/25.
 */

public class DBHelper extends SQLiteOpenHelper {

    private static final String DATABASE_NAME = "test.db";
    private static final int DATABASE_VERSION = 2;

    public DBHelper(Context context) {
        //CursorFactory设置为null,使用默认值
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    //数据库第一次被创建时onCreate会被调用
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE IF NOT EXISTS tzzxinfo" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "lx VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tzzxdbinfo" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "belongid VARCHAR," +
                "bringid VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tbdinfo" +
                "(id INTEGER primary key autoincrement," +
                "zzxbh VARCHAR," +
                "xm VARCHAR," +
                "lx VARCHAR," +
                "zt VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tpdinfo" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tpdzzxinfo" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tpdmore" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "did VARCHAR)");


    }

    //如果DATABASE_VERSION值被改为2,系统发现现有数据库版本不同,即会调用onUpgrade
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        db.execSQL("CREATE TABLE IF NOT EXISTS tzzxinfo" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "lx VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tzzxdbinfo" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "belongid VARCHAR," +
                "bringid VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tbdinfo" +
                "(id INTEGER primary key autoincrement," +
                "zzxbh VARCHAR," +
                "xm VARCHAR," +
                "lx VARCHAR," +
                "zt VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tpdinfo" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tpdzzxinfo" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "did VARCHAR)");

        db.execSQL("CREATE TABLE IF NOT EXISTS tpdmore" +
                "(id INTEGER primary key autoincrement," +
                "bh VARCHAR," +
                "did VARCHAR)");


    }
}
